"""
    Author:
    Date: 2018-11-08

    微信管理后台-充值管理
"""

from django.shortcuts import render

from entities import pay_mgr
from entities.consts import *

from .. import helpers
from .. helpers import gma_login_required


@gma_login_required
def index(request):
    """ 代理管理首页 """
    context = helpers.build_context(request)
    context['total_recharge_amount'] = pay_mgr.get_total_recharge_amount()
    return render(request, 'gma/recharge/recharge_home.html', context)


@gma_login_required
def recharge_list(request, count):
    """ 显示最近的充值记录 """
    context = helpers.build_context(request)
    context['logs'] = pay_mgr.get_recharge_list(count)
    for log in context['logs']:
        log['recharge_type_desp'] = get_recharge_type_desp(log['type'])
    return render(request, 'gma/recharge/recharge_list.html', context)


if __name__ == '__main__':
    print('ok')
